package com.ruoyi.asset.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.asset.domain.PropertyParking;
import com.ruoyi.asset.service.IPropertyParkingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车位档案Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/asset/parking")
public class PropertyParkingController extends BaseController
{
    @Autowired
    private IPropertyParkingService propertyParkingService;

    /**
     * 查询车位档案列表
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyParking propertyParking)
    {
        startPage();
        List<PropertyParking> list = propertyParkingService.selectPropertyParkingList(propertyParking);
        return getDataTable(list);
    }

    /**
     * 导出车位档案列表
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:export')")
    @Log(title = "车位档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyParking propertyParking)
    {
        List<PropertyParking> list = propertyParkingService.selectPropertyParkingList(propertyParking);
        ExcelUtil<PropertyParking> util = new ExcelUtil<PropertyParking>(PropertyParking.class);
        util.exportExcel(response, list, "车位档案数据");
    }

    /**
     * 获取车位档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:query')")
    @GetMapping(value = "/{parkingId}")
    public AjaxResult getInfo(@PathVariable("parkingId") Long parkingId)
    {
        return success(propertyParkingService.selectPropertyParkingByParkingId(parkingId));
    }

    /**
     * 新增车位档案
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:add')")
    @Log(title = "车位档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyParking propertyParking)
    {
        return toAjax(propertyParkingService.insertPropertyParking(propertyParking));
    }

    /**
     * 修改车位档案
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:edit')")
    @Log(title = "车位档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyParking propertyParking)
    {
        return toAjax(propertyParkingService.updatePropertyParking(propertyParking));
    }

    /**
     * 删除车位档案
     */
    @PreAuthorize("@ss.hasPermi('asset:parking:remove')")
    @Log(title = "车位档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parkingIds}")
    public AjaxResult remove(@PathVariable Long[] parkingIds)
    {
        return toAjax(propertyParkingService.deletePropertyParkingByParkingIds(parkingIds));
    }
}
